<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jwt</title>
    <script src="./api.js"></script>
</head>
<body>
    <h1>jwt</h1>
    <script>
        function login() {
            let params = {
                method: 'POST',
                url: '/login',
                data: {username: 'admin', password: 'admin'},
            };
            api(params).then(res => {
                if (res.code == 0) {
                    localStorage.setItem('token', res.token);
                }
            })
            api({
                method: 'GET',
                url: '/admin'
            })
        }
        login();
    </script>
</body>
</html>